package com.yh.workbill.base;

import android.os.Bundle;

import com.yh.workbill.view.LoadProgressDialog;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public abstract class BaseFragment extends Fragment {

    private LoadProgressDialog loaddingDialog;

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initJetPck();
        initSetting();
        initObserver();
        initDefaultMethod();
        initData();
        initClick();
    }

    public abstract void initJetPck();

    public abstract void initSetting();

    public abstract void initObserver();

    public abstract void initDefaultMethod();

    public abstract void initClick();

    public abstract void initData();

    public void showLoaddingDialog(String content, boolean isCancelable) {
        if (loaddingDialog == null) {
            loaddingDialog = new LoadProgressDialog(requireActivity(), content, isCancelable);
        }
        loaddingDialog.showLoadding();
    }

    public void hideLoaddingDialog() {
        if (loaddingDialog != null && loaddingDialog.isShowing()) {
            loaddingDialog.dismissLoadding();
            loaddingDialog = null;
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        hideLoaddingDialog();
    }

}
